/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DAOClass;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 *
 * @author Phong
 */
public class feedback extends Connect{

    private Connection conn = null;
    private PreparedStatement sql;
    public feedback()   {
        super();
    }

    public void close() {
        try {
            if (conn != null)
                conn.close();
        } catch (SQLException ex)  {
           ex.printStackTrace();
        }
    }
    public boolean Insert(String user, String title, String content,String mail, String tel, String Date, int Status) {
        boolean flag = true;
        conn = this.getConnect();
        try {
            sql = conn.prepareStatement("EXEC InsertFeedback ?, ?, ?, ?, ?, ?, ?");
            sql.setString(1, user);
            sql.setString(2, title);
            sql.setString(3, content);
            sql.setString(4, mail);
            sql.setString(5, tel);
            sql.setString(6, Date);
            sql.setInt(7, Status);
            if (sql.executeUpdate() == 1)
                return flag;
            else
                flag = false;
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return flag;
    }

    public static void main(String[] args)  {
        java.util.Date d = new java.util.Date();
        SimpleDateFormat date = new SimpleDateFormat("MM/dd/yyyy HH:MM:s");
        String sDate = date.format(d);
        System.out.println(sDate);
        
        boolean flag = new feedback().Insert("Guest", "zdgsdh", "shsdhsdh","AFAFS@DGKJD.C0M","2862672","11/03/2009 03:11:19", 0);
        System.out.println(flag);
    }
}
